<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libcoap: async.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">libcoap<span id="projectnumber">&#160;4.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function() { init_codefold(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('async_8c_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="headertitle"><div class="title">async.c</div></div>
</div><!--header-->
<div class="contents">
<a href="async_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/* async.c -- state management for asynchronous messages</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> *</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> * Copyright (C) 2010,2011 Olaf Bergmann &lt;bergmann@tzi.org&gt;</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> *</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> * This file is part of the CoAP library libcoap. Please see</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="comment"> * README for terms of use.</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="comment"> */</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#ifndef WITHOUT_ASYNC</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span> </div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="preprocessor">#include &quot;coap_config.h&quot;</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#include &quot;<a class="code" href="coap_8h.html">coap.h</a>&quot;</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#include &quot;<a class="code" href="async_8h.html">async.h</a>&quot;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#include &quot;<a class="code" href="coap__debug_8h.html">coap_debug.h</a>&quot;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &quot;<a class="code" href="mem_8h.html">mem.h</a>&quot;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &quot;<a class="code" href="utlist_8h.html">utlist.h</a>&quot;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="comment">/* utlist-style macros for searching pairs in linked lists */</span></div>
<div class="foldopen" id="foldopen00024" data-start="" data-end="">
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"><a class="line" href="async_8c.html#a873cf0a6cd02fd3b146199dd26e8f0cf">   24</a></span><span class="preprocessor">#define SEARCH_PAIR(head,out,field1,val1,field2,val2)   \</span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">  SEARCH_PAIR2(head,out,field1,val1,field2,val2,next)</span></div>
</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="foldopen" id="foldopen00027" data-start="" data-end="">
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="async_8c.html#a67ecb5d953c544e03b9325279285632e">   27</a></span><span class="preprocessor">#define SEARCH_PAIR2(head,out,field1,val1,field2,val2,next)             \</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span><span class="preprocessor">  do {                                                                  \</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="preprocessor">    LL_FOREACH2(head,out,next) {                                        \</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span><span class="preprocessor">      if ((out)-&gt;field1 == (val1) &amp;&amp; (out)-&gt;field2 == (val2)) break;    \</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="preprocessor">    }                                                                   \</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="preprocessor">} while(0)</span></div>
</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *</div>
<div class="foldopen" id="foldopen00035" data-start="{" data-end="}">
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="group__coap__async.html#ga7ff79a6925e27b7146184135023e1b40">   35</a></span><a class="code hl_function" href="group__coap__async.html#ga7ff79a6925e27b7146184135023e1b40">coap_register_async</a>(<a class="code hl_struct" href="structcoap__context__t.html">coap_context_t</a> *context, <a class="code hl_struct" href="structcoap__session__t.html">coap_session_t</a> *session,</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>                    <a class="code hl_struct" href="structcoap__pdu__t.html">coap_pdu_t</a> *request, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> flags, <span class="keywordtype">void</span> *data) {</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>  <a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *s;</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span>  <a class="code hl_typedef" href="pdu_8h.html#ac60fb9284ace878df3db4a2d621d9a8d">coap_tid_t</a> <span class="keywordtype">id</span> = request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a65877a685b1f3428d3dc872af075ddc1">tid</a>;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span>  <a class="code hl_define" href="async_8c.html#a873cf0a6cd02fd3b146199dd26e8f0cf">SEARCH_PAIR</a>(context-&gt;<a class="code hl_variable" href="structcoap__context__t.html#a4f287951eac36a9488fd9524eb1cbdb8">async_state</a>,s,session,session,<span class="keywordtype">id</span>,<span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>  <span class="keywordflow">if</span> (s != NULL) {</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>    <span class="comment">/* We must return NULL here as the caller must know that he is</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span><span class="comment">     * responsible for releasing @p data. */</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    <a class="code hl_define" href="group__logging.html#gaff2785484e756c8ec2fce408f9b81f0f">coap_log</a>(<a class="code hl_enumvalue" href="group__logging.html#gga53c7b97a7af4d62d8c1678d658cc7446ab9f002c6ffbfd511da8090213227454e">LOG_DEBUG</a>,</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>         <span class="stringliteral">&quot;asynchronous state for transaction %d already registered\n&quot;</span>, <span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>  }</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span> </div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>  <span class="comment">/* store information for handling the asynchronous task */</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>  s = (<a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *)<a class="code hl_function" href="mem_8h.html#a26f40acd710e6c964242c2e0cd789375">coap_malloc</a>(<span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a>));</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>  <span class="keywordflow">if</span> (!s) {</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>    <a class="code hl_define" href="group__logging.html#gaff2785484e756c8ec2fce408f9b81f0f">coap_log</a>(<a class="code hl_enumvalue" href="group__logging.html#gga53c7b97a7af4d62d8c1678d658cc7446a3537fbf756308b6267dd4354615eb413">LOG_CRIT</a>, <span class="stringliteral">&quot;coap_register_async: insufficient memory\n&quot;</span>);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>    <span class="keywordflow">return</span> NULL;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>  }</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>  memset(s, 0, <span class="keyword">sizeof</span>(<a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a>));</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span> </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>  <span class="comment">/* set COAP_ASYNC_CONFIRM according to request&#39;s type */</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>  s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a34237f37d4c44962f4c4f0dbf39560c1">flags</a> = flags &amp; ~COAP_ASYNC_CONFIRM;</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>  <span class="keywordflow">if</span> (request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a0d5796b82924c69852860053020d0684">type</a> == <a class="code hl_define" href="pdu_8h.html#ab6ad49de4b14e7cf5bd0a2a1a87eef2f">COAP_MESSAGE_CON</a>)</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>    s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a34237f37d4c44962f4c4f0dbf39560c1">flags</a> |= <a class="code hl_define" href="group__coap__async.html#gaf3c112eaa3f262731ed3507a228bf776">COAP_ASYNC_CONFIRM</a>;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>  s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a8bfdf12963290e8284e1510b093b17c1">appdata</a> = data;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span>  s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a9c0087c5ff046a7f49b036f1d1d22657">session</a> = <a class="code hl_function" href="coap__session_8c.html#ae37bac62f8de2cecd968ec1c26eb23b4">coap_session_reference</a>( session );</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span>  s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#af6bd1cb2573d3b38e5c1c1175d52f471">id</a> = id;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span> </div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>  <span class="keywordflow">if</span> (request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a8c05f6d455ff81d7751ddb61233a455b">token_length</a>) {</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>    <span class="comment">/* A token can be up to 8 bytes */</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>    s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a9ac15543c19c679be1f77442671454fb">tokenlen</a> = (request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a8c05f6d455ff81d7751ddb61233a455b">token_length</a> &gt; 8) ? 8 : request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a8c05f6d455ff81d7751ddb61233a455b">token_length</a>;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>    memcpy(s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#ada1019c039810e4f719866f773ac2fb8">token</a>, request-&gt;<a class="code hl_variable" href="structcoap__pdu__t.html#a3c42c790abb815d722fbebcd7702a200">token</a>, s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a9ac15543c19c679be1f77442671454fb">tokenlen</a>);</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>  }</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>  <a class="code hl_function" href="group__coap__async.html#ga45f50bcf81bc5fb17a3ee9907e7beae7">coap_touch_async</a>(s);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>  <a class="code hl_define" href="utlist_8h.html#a851fb4b583b0dc000097eeee6dd551d4">LL_PREPEND</a>(context-&gt;<a class="code hl_variable" href="structcoap__context__t.html#a4f287951eac36a9488fd9524eb1cbdb8">async_state</a>, s);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>  <span class="keywordflow">return</span> s;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>}</div>
</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span> </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span><a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *</div>
<div class="foldopen" id="foldopen00082" data-start="{" data-end="}">
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"><a class="line" href="group__coap__async.html#gabcb03afad78869b28826d780f37c818b">   82</a></span><a class="code hl_function" href="group__coap__async.html#gabcb03afad78869b28826d780f37c818b">coap_find_async</a>(<a class="code hl_struct" href="structcoap__context__t.html">coap_context_t</a> *context, <a class="code hl_struct" href="structcoap__session__t.html">coap_session_t</a> *session, <a class="code hl_typedef" href="pdu_8h.html#ac60fb9284ace878df3db4a2d621d9a8d">coap_tid_t</a> <span class="keywordtype">id</span>) {</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>  <a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *tmp;</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span>  <a class="code hl_define" href="async_8c.html#a873cf0a6cd02fd3b146199dd26e8f0cf">SEARCH_PAIR</a>(context-&gt;<a class="code hl_variable" href="structcoap__context__t.html#a4f287951eac36a9488fd9524eb1cbdb8">async_state</a>,tmp,session,session,<span class="keywordtype">id</span>,<span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>  <span class="keywordflow">return</span> tmp;</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span>}</div>
</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span><span class="keywordtype">int</span></div>
<div class="foldopen" id="foldopen00089" data-start="{" data-end="}">
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"><a class="line" href="group__coap__async.html#gadec4e4c177dd62a1853360ddbf69258e">   89</a></span><a class="code hl_function" href="group__coap__async.html#gadec4e4c177dd62a1853360ddbf69258e">coap_remove_async</a>(<a class="code hl_struct" href="structcoap__context__t.html">coap_context_t</a> *context, <a class="code hl_struct" href="structcoap__session__t.html">coap_session_t</a> *session,</div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>                  <a class="code hl_typedef" href="pdu_8h.html#ac60fb9284ace878df3db4a2d621d9a8d">coap_tid_t</a> <span class="keywordtype">id</span>, <a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> **s) {</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>  <a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *tmp = <a class="code hl_function" href="group__coap__async.html#gabcb03afad78869b28826d780f37c818b">coap_find_async</a>(context, session, <span class="keywordtype">id</span>);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span> </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>  <span class="keywordflow">if</span> (tmp)</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    <a class="code hl_define" href="utlist_8h.html#a34a4e54d488753465f6e87bb63b93c0e">LL_DELETE</a>(context-&gt;<a class="code hl_variable" href="structcoap__context__t.html#a4f287951eac36a9488fd9524eb1cbdb8">async_state</a>,tmp);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>  *s = tmp;</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>  <span class="keywordflow">return</span> tmp != NULL;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>}</div>
</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span> </div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span><span class="keywordtype">void</span></div>
<div class="foldopen" id="foldopen00101" data-start="{" data-end="}">
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"><a class="line" href="group__coap__async.html#ga32024a34a383832e6692d3a439fc67c7">  101</a></span><a class="code hl_function" href="group__coap__async.html#ga32024a34a383832e6692d3a439fc67c7">coap_free_async</a>(<a class="code hl_struct" href="structcoap__async__state__t.html">coap_async_state_t</a> *s) {</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>  <span class="keywordflow">if</span> (s) {</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>    <span class="keywordflow">if</span> (s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a9c0087c5ff046a7f49b036f1d1d22657">session</a>) {</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>      <a class="code hl_function" href="coap__session_8c.html#a9aee135ba884d7c143b11bc42fd23e53">coap_session_release</a>(s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a9c0087c5ff046a7f49b036f1d1d22657">session</a>);</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>    }</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>    <span class="keywordflow">if</span> ((s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a34237f37d4c44962f4c4f0dbf39560c1">flags</a> &amp; <a class="code hl_define" href="group__coap__async.html#gab13ab4a40fab483ee2eaef1ac39fd1d8">COAP_ASYNC_RELEASE_DATA</a>) != 0) {</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>      <a class="code hl_function" href="mem_8h.html#a1e46a1505bb13f03fdacd5d1b32502a6">coap_free</a>(s-&gt;<a class="code hl_variable" href="structcoap__async__state__t.html#a8bfdf12963290e8284e1510b093b17c1">appdata</a>);</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>    }</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>    <a class="code hl_function" href="mem_8h.html#a1e46a1505bb13f03fdacd5d1b32502a6">coap_free</a>(s);</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span>  }</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>}</div>
</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span><span class="keywordtype">void</span> does_not_exist(<span class="keywordtype">void</span>);        <span class="comment">/* make some compilers happy */</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span><span class="preprocessor">#endif </span><span class="comment">/* WITHOUT_ASYNC */</span><span class="preprocessor"></span></div>
<div class="ttc" id="aasync_8c_html_a873cf0a6cd02fd3b146199dd26e8f0cf"><div class="ttname"><a href="async_8c.html#a873cf0a6cd02fd3b146199dd26e8f0cf">SEARCH_PAIR</a></div><div class="ttdeci">#define SEARCH_PAIR(head, out, field1, val1, field2, val2)</div><div class="ttdef"><b>Definition</b> <a href="async_8c_source.html#l00024">async.c:24</a></div></div>
<div class="ttc" id="aasync_8h_html"><div class="ttname"><a href="async_8h.html">async.h</a></div><div class="ttdoc">State management for asynchronous messages.</div></div>
<div class="ttc" id="acoap_8h_html"><div class="ttname"><a href="coap_8h.html">coap.h</a></div></div>
<div class="ttc" id="acoap__debug_8h_html"><div class="ttname"><a href="coap__debug_8h.html">coap_debug.h</a></div></div>
<div class="ttc" id="acoap__session_8c_html_a9aee135ba884d7c143b11bc42fd23e53"><div class="ttname"><a href="coap__session_8c.html#a9aee135ba884d7c143b11bc42fd23e53">coap_session_release</a></div><div class="ttdeci">void coap_session_release(coap_session_t *session)</div><div class="ttdoc">Decrement reference counter on a session.</div><div class="ttdef"><b>Definition</b> <a href="coap__session_8c_source.html#l00077">coap_session.c:77</a></div></div>
<div class="ttc" id="acoap__session_8c_html_ae37bac62f8de2cecd968ec1c26eb23b4"><div class="ttname"><a href="coap__session_8c.html#ae37bac62f8de2cecd968ec1c26eb23b4">coap_session_reference</a></div><div class="ttdeci">coap_session_t * coap_session_reference(coap_session_t *session)</div><div class="ttdoc">Increment reference counter on a session.</div><div class="ttdef"><b>Definition</b> <a href="coap__session_8c_source.html#l00071">coap_session.c:71</a></div></div>
<div class="ttc" id="agroup__coap__async_html_ga32024a34a383832e6692d3a439fc67c7"><div class="ttname"><a href="group__coap__async.html#ga32024a34a383832e6692d3a439fc67c7">coap_free_async</a></div><div class="ttdeci">void coap_free_async(coap_async_state_t *s)</div><div class="ttdoc">Releases the memory that was allocated by coap_async_state_init() for the object s.</div><div class="ttdef"><b>Definition</b> <a href="async_8c_source.html#l00101">async.c:101</a></div></div>
<div class="ttc" id="agroup__coap__async_html_ga45f50bcf81bc5fb17a3ee9907e7beae7"><div class="ttname"><a href="group__coap__async.html#ga45f50bcf81bc5fb17a3ee9907e7beae7">coap_touch_async</a></div><div class="ttdeci">COAP_STATIC_INLINE void coap_touch_async(coap_async_state_t *s)</div><div class="ttdoc">Updates the time stamp of s.</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00143">async.h:143</a></div></div>
<div class="ttc" id="agroup__coap__async_html_ga7ff79a6925e27b7146184135023e1b40"><div class="ttname"><a href="group__coap__async.html#ga7ff79a6925e27b7146184135023e1b40">coap_register_async</a></div><div class="ttdeci">coap_async_state_t * coap_register_async(coap_context_t *context, coap_session_t *session, coap_pdu_t *request, unsigned char flags, void *data)</div><div class="ttdoc">Allocates a new coap_async_state_t object and fills its fields according to the given request.</div><div class="ttdef"><b>Definition</b> <a href="async_8c_source.html#l00035">async.c:35</a></div></div>
<div class="ttc" id="agroup__coap__async_html_gab13ab4a40fab483ee2eaef1ac39fd1d8"><div class="ttname"><a href="group__coap__async.html#gab13ab4a40fab483ee2eaef1ac39fd1d8">COAP_ASYNC_RELEASE_DATA</a></div><div class="ttdeci">#define COAP_ASYNC_RELEASE_DATA</div><div class="ttdoc">release application data on destruction</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00062">async.h:62</a></div></div>
<div class="ttc" id="agroup__coap__async_html_gabcb03afad78869b28826d780f37c818b"><div class="ttname"><a href="group__coap__async.html#gabcb03afad78869b28826d780f37c818b">coap_find_async</a></div><div class="ttdeci">coap_async_state_t * coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id)</div><div class="ttdoc">Retrieves the object identified by id from the list of asynchronous transactions that are registered ...</div><div class="ttdef"><b>Definition</b> <a href="async_8c_source.html#l00082">async.c:82</a></div></div>
<div class="ttc" id="agroup__coap__async_html_gadec4e4c177dd62a1853360ddbf69258e"><div class="ttname"><a href="group__coap__async.html#gadec4e4c177dd62a1853360ddbf69258e">coap_remove_async</a></div><div class="ttdeci">int coap_remove_async(coap_context_t *context, coap_session_t *session, coap_tid_t id, coap_async_state_t **s)</div><div class="ttdoc">Removes the state object identified by id from context.</div><div class="ttdef"><b>Definition</b> <a href="async_8c_source.html#l00089">async.c:89</a></div></div>
<div class="ttc" id="agroup__coap__async_html_gaf3c112eaa3f262731ed3507a228bf776"><div class="ttname"><a href="group__coap__async.html#gaf3c112eaa3f262731ed3507a228bf776">COAP_ASYNC_CONFIRM</a></div><div class="ttdeci">#define COAP_ASYNC_CONFIRM</div><div class="ttdoc">send confirmable response</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00057">async.h:57</a></div></div>
<div class="ttc" id="agroup__logging_html_gaff2785484e756c8ec2fce408f9b81f0f"><div class="ttname"><a href="group__logging.html#gaff2785484e756c8ec2fce408f9b81f0f">coap_log</a></div><div class="ttdeci">#define coap_log(level,...)</div><div class="ttdoc">Logging function.</div><div class="ttdef"><b>Definition</b> <a href="coap__debug_8h_source.html#l00122">coap_debug.h:122</a></div></div>
<div class="ttc" id="agroup__logging_html_gga53c7b97a7af4d62d8c1678d658cc7446a3537fbf756308b6267dd4354615eb413"><div class="ttname"><a href="group__logging.html#gga53c7b97a7af4d62d8c1678d658cc7446a3537fbf756308b6267dd4354615eb413">LOG_CRIT</a></div><div class="ttdeci">@ LOG_CRIT</div><div class="ttdoc">Critical.</div><div class="ttdef"><b>Definition</b> <a href="coap__debug_8h_source.html#l00044">coap_debug.h:44</a></div></div>
<div class="ttc" id="agroup__logging_html_gga53c7b97a7af4d62d8c1678d658cc7446ab9f002c6ffbfd511da8090213227454e"><div class="ttname"><a href="group__logging.html#gga53c7b97a7af4d62d8c1678d658cc7446ab9f002c6ffbfd511da8090213227454e">LOG_DEBUG</a></div><div class="ttdeci">@ LOG_DEBUG</div><div class="ttdoc">Debug.</div><div class="ttdef"><b>Definition</b> <a href="coap__debug_8h_source.html#l00050">coap_debug.h:49</a></div></div>
<div class="ttc" id="amem_8h_html"><div class="ttname"><a href="mem_8h.html">mem.h</a></div></div>
<div class="ttc" id="amem_8h_html_a1e46a1505bb13f03fdacd5d1b32502a6"><div class="ttname"><a href="mem_8h.html#a1e46a1505bb13f03fdacd5d1b32502a6">coap_free</a></div><div class="ttdeci">COAP_STATIC_INLINE void coap_free(void *object)</div><div class="ttdoc">Wrapper function to coap_free_type() for backwards compatibility.</div><div class="ttdef"><b>Definition</b> <a href="mem_8h_source.html#l00082">mem.h:82</a></div></div>
<div class="ttc" id="amem_8h_html_a26f40acd710e6c964242c2e0cd789375"><div class="ttname"><a href="mem_8h.html#a26f40acd710e6c964242c2e0cd789375">coap_malloc</a></div><div class="ttdeci">COAP_STATIC_INLINE void * coap_malloc(size_t size)</div><div class="ttdoc">Wrapper function to coap_malloc_type() for backwards compatibility.</div><div class="ttdef"><b>Definition</b> <a href="mem_8h_source.html#l00075">mem.h:75</a></div></div>
<div class="ttc" id="apdu_8h_html_ab6ad49de4b14e7cf5bd0a2a1a87eef2f"><div class="ttname"><a href="pdu_8h.html#ab6ad49de4b14e7cf5bd0a2a1a87eef2f">COAP_MESSAGE_CON</a></div><div class="ttdeci">#define COAP_MESSAGE_CON</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00072">pdu.h:72</a></div></div>
<div class="ttc" id="apdu_8h_html_ac60fb9284ace878df3db4a2d621d9a8d"><div class="ttname"><a href="pdu_8h.html#ac60fb9284ace878df3db4a2d621d9a8d">coap_tid_t</a></div><div class="ttdeci">int coap_tid_t</div><div class="ttdoc">coap_tid_t is used to store CoAP transaction id, i.e.</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00238">pdu.h:238</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html"><div class="ttname"><a href="structcoap__async__state__t.html">coap_async_state_t</a></div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00031">async.h:31</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_a34237f37d4c44962f4c4f0dbf39560c1"><div class="ttname"><a href="structcoap__async__state__t.html#a34237f37d4c44962f4c4f0dbf39560c1">coap_async_state_t::flags</a></div><div class="ttdeci">unsigned char flags</div><div class="ttdoc">holds the flags to control behaviour</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00032">async.h:32</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_a8bfdf12963290e8284e1510b093b17c1"><div class="ttname"><a href="structcoap__async__state__t.html#a8bfdf12963290e8284e1510b093b17c1">coap_async_state_t::appdata</a></div><div class="ttdeci">void * appdata</div><div class="ttdoc">This field can be used to register opaque application data with the asynchronous state object.</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00045">async.h:45</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_a9ac15543c19c679be1f77442671454fb"><div class="ttname"><a href="structcoap__async__state__t.html#a9ac15543c19c679be1f77442671454fb">coap_async_state_t::tokenlen</a></div><div class="ttdeci">size_t tokenlen</div><div class="ttdoc">length of the token</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00050">async.h:50</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_a9c0087c5ff046a7f49b036f1d1d22657"><div class="ttname"><a href="structcoap__async__state__t.html#a9c0087c5ff046a7f49b036f1d1d22657">coap_async_state_t::session</a></div><div class="ttdeci">coap_session_t * session</div><div class="ttdoc">transaction session</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00047">async.h:47</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_ada1019c039810e4f719866f773ac2fb8"><div class="ttname"><a href="structcoap__async__state__t.html#ada1019c039810e4f719866f773ac2fb8">coap_async_state_t::token</a></div><div class="ttdeci">uint8_t token[8]</div><div class="ttdoc">the token to use in a response</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00051">async.h:51</a></div></div>
<div class="ttc" id="astructcoap__async__state__t_html_af6bd1cb2573d3b38e5c1c1175d52f471"><div class="ttname"><a href="structcoap__async__state__t.html#af6bd1cb2573d3b38e5c1c1175d52f471">coap_async_state_t::id</a></div><div class="ttdeci">coap_tid_t id</div><div class="ttdoc">transaction id</div><div class="ttdef"><b>Definition</b> <a href="async_8h_source.html#l00048">async.h:48</a></div></div>
<div class="ttc" id="astructcoap__context__t_html"><div class="ttname"><a href="structcoap__context__t.html">coap_context_t</a></div><div class="ttdoc">The CoAP stack's global state is stored in a coap_context_t object.</div><div class="ttdef"><b>Definition</b> <a href="net_8h_source.html#l00148">net.h:148</a></div></div>
<div class="ttc" id="astructcoap__context__t_html_a4f287951eac36a9488fd9524eb1cbdb8"><div class="ttname"><a href="structcoap__context__t.html#a4f287951eac36a9488fd9524eb1cbdb8">coap_context_t::async_state</a></div><div class="ttdeci">struct coap_async_state_t * async_state</div><div class="ttdoc">list of asynchronous transactions</div><div class="ttdef"><b>Definition</b> <a href="net_8h_source.html#l00158">net.h:158</a></div></div>
<div class="ttc" id="astructcoap__pdu__t_html"><div class="ttname"><a href="structcoap__pdu__t.html">coap_pdu_t</a></div><div class="ttdoc">structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00285">pdu.h:285</a></div></div>
<div class="ttc" id="astructcoap__pdu__t_html_a0d5796b82924c69852860053020d0684"><div class="ttname"><a href="structcoap__pdu__t.html#a0d5796b82924c69852860053020d0684">coap_pdu_t::type</a></div><div class="ttdeci">uint8_t type</div><div class="ttdoc">message type</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00286">pdu.h:286</a></div></div>
<div class="ttc" id="astructcoap__pdu__t_html_a3c42c790abb815d722fbebcd7702a200"><div class="ttname"><a href="structcoap__pdu__t.html#a3c42c790abb815d722fbebcd7702a200">coap_pdu_t::token</a></div><div class="ttdeci">uint8_t * token</div><div class="ttdoc">first byte of token, if any, or options</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00296">pdu.h:296</a></div></div>
<div class="ttc" id="astructcoap__pdu__t_html_a65877a685b1f3428d3dc872af075ddc1"><div class="ttname"><a href="structcoap__pdu__t.html#a65877a685b1f3428d3dc872af075ddc1">coap_pdu_t::tid</a></div><div class="ttdeci">uint16_t tid</div><div class="ttdoc">transaction id, if any, in regular host byte order</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00291">pdu.h:291</a></div></div>
<div class="ttc" id="astructcoap__pdu__t_html_a8c05f6d455ff81d7751ddb61233a455b"><div class="ttname"><a href="structcoap__pdu__t.html#a8c05f6d455ff81d7751ddb61233a455b">coap_pdu_t::token_length</a></div><div class="ttdeci">uint8_t token_length</div><div class="ttdoc">length of Token</div><div class="ttdef"><b>Definition</b> <a href="pdu_8h_source.html#l00290">pdu.h:290</a></div></div>
<div class="ttc" id="astructcoap__session__t_html"><div class="ttname"><a href="structcoap__session__t.html">coap_session_t</a></div><div class="ttdef"><b>Definition</b> <a href="coap__session_8h_source.html#l00056">coap_session.h:56</a></div></div>
<div class="ttc" id="autlist_8h_html"><div class="ttname"><a href="utlist_8h.html">utlist.h</a></div></div>
<div class="ttc" id="autlist_8h_html_a34a4e54d488753465f6e87bb63b93c0e"><div class="ttname"><a href="utlist_8h.html#a34a4e54d488753465f6e87bb63b93c0e">LL_DELETE</a></div><div class="ttdeci">#define LL_DELETE(head, del)</div><div class="ttdef"><b>Definition</b> <a href="utlist_8h_source.html#l00385">utlist.h:385</a></div></div>
<div class="ttc" id="autlist_8h_html_a851fb4b583b0dc000097eeee6dd551d4"><div class="ttname"><a href="utlist_8h.html#a851fb4b583b0dc000097eeee6dd551d4">LL_PREPEND</a></div><div class="ttdeci">#define LL_PREPEND(head, add)</div><div class="ttdef"><b>Definition</b> <a href="utlist_8h_source.html#l00314">utlist.h:314</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="async_8c.html">async.c</a></li>
    <li class="footer">Generated on Fri Dec 27 2024 09:57:44 for libcoap by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  </ul>
</div>
</body>
</html>
